Handling user input
You can set how and which elements in your application react to user input. In Kanzi, to handle user input you can:
- Enable gesture recognition for nodes. See Using input manipulators.
- Define which nodes receive user input. See Defining which node receives user input.
- Set the size of the input area of nodes. See Setting the size of the input area.
- Set how and which nodes react to keyboard input. See Handling keyboard input.

For these Kanzi nodes you do not have to create input manipulators manually, because they handle input by default:
- Button nodes. See Using the Button nodes.
- Toggle Button nodes. See Using the Toggle Button nodes.
- List Box nodes. See List Box nodes.
- List Box Item Container prefabs. See Using the List Box Item Container prefabs.
- Scroll View nodes. See Using the Scroll View nodes.
- Slider nodes. See Using the Slider nodes.
Use triggers and actions to create interactions based on user input. See Using triggers.
Using input manipulators
Kanzi provides low and high-level access to input:
- The high-level system provides input in terms of gestures, such as click, pan, pinch, and so on. It is recommended to use the high-level system to bind gestures to the UI components or application functionality.
- The low-level input system reports raw touch events as they happen in nodes.
Kanzi provides input manipulators to enable gesture recognition for nodes in your Kanzi project. You can assign the manipulators through the API.
Kanzi provides these input manipulators:
- Use the click manipulator to enable users to click or tap nodes in your Kanzi application. See Using the click manipulator.
- Use the long-press manipulator to enable users to long-press nodes in your Kanzi application. See Using the long-press manipulator.
- Use the multi-click manipulator to enable users to multi-click or multi-tap nodes in your Kanzi application. See Using the multi-click manipulator.
- Use the drag-and-drop manipulator to enable users to drag and drop nodes in your Kanzi application. See Using the drag-and-drop manipulator.
- Use the pan manipulator to enable users to move nodes in your Kanzi application. See Using the pan manipulator.
- Use the pinch manipulator to enable users to zoom and rotate nodes in your Kanzi application. See Using the pinch manipulator.
InputManipulator is the base class for manipulators, and functions such as ClickManipulator::create and PanManipulator::create create input manipulators responsible for the corresponding gesture recognition.
When you create an input manipulator, to recognize the gesture, attach it to the node with Node::addInputManipulator. This attaches all the children of the node too.
Attached manipulator generates messages in response to user actions. Each manipulator uses messages to report different events during gesture recognition, such as PanManipulator::StartedMessage, PanManipulator::MovedMessage, PanManipulator::FinishedMessage for the pan manipulator and so on.
Defining which node receives user input
When you create your user interface take special care how your application handles user input, because only one node can receive user input at a time. For example, define whether a click is handled by the node in the front or by the one behind it.
Kanzi uses hit testing to determine the nodes that receive input. In practice, hit testing projects a ray from the camera towards the 3D scene based on the screen coordinates of the input event.
By default hit testing is enabled for the Button, List Box Item Container, Scroll View, and Slider nodes. To enable hit testing for a node of any other node type, add and enable the Hit Testable property to that node.
The first node from the Camera node whose bounding box is intersected and has the Hit Testable property enabled, receives the input, consumes the event, and generates set actions, such as sending a click message.
For example, if you place two Box nodes so that the BoxFront node is in front of the BoxRear node and occludes it completely:
- The BoxFront node receives the input when the Hit Testable property of the BoxFront node is enabled.
- The BoxRear node receives the input even though it is occluded by the BoxFront node when:
- Hit Testable property of the BoxFront node is disabled
- Hit Testable property of the BoxRear node is enabled
Setting the size of the input area
When you want to change the area within which a node receives input, use the Hit Testable Container property. In Kanzi hit testing for all nodes is by default based on the layout size of each node. Use the Hit Testable Container property to include in the input area the layout size of the node that has the property and the layout size of any of its child nodes, rather than just the bounding volume of the node.
By default the Hit Testable Container property is enabled for the Button, List Box Item Container, Scroll View, and Slider 3D nodes. To set the size of the input area for a node of any other node type, add and enable the Hit Testable Container and Hit Testable properties.
For example, a Stack Layout 3D node which contains a Box node receives click input:
- When the Hit Testable Container property of the Stack Layout 3D node is disabled, from the area defined by the Width, Height, and Depth properties of the Box node
- When the Hit Testable Container property of the Stack Layout 3D node is enabled, from the area defined by the Layout Width, Layout Height, and Layout Depth properties of either the Stack Layout 3D and the Box node
See also
Using the long-press manipulator
Using the multi-click manipulator
Using the drag-and-drop manipulator